package overrideoverwrite;

/**
 * @ClassName EmployeeTest
 * @Date 2024/11/27 14:49 05
 * @Author Jack Chen
 * @Description serenity-cucumber-auto-project-jack
 * @Version 1.0
 */

public class EmployeeTest {

    public static void main(String[] args) throws CloneNotSupportedException, InterruptedException {
        var  e1 = new Employee("jack", 14000 );
        //浅拷贝1
        System.out.println("浅拷贝1");
        var  e2 = e1;
        System.out.println("e1:" + e1);
        System.out.println("E2:" + e2);
        e2.setSalary(288888);
        e1.setName("changed name");
        System.out.println("e1:" + e1);
        System.out.println("E2:" + e2);
        System.out.println(e2.equals(e1));

        // 深拷贝伴随浅拷贝过程  默认的Object.clone()
        System.out.println("深拷贝伴随浅拷贝过程  默认的Object.clone()");
        Employee e3 = e1.clone();
        e3.setName("Jack new");
        e3.setSalary(10000);
        Thread.sleep(2000);
        System.out.println("E1:" + e1);
        System.out.println("E3:" + e3);

        // 深拷贝
        //create a new Date object
//        System.out.println("深拷贝1");
//        Thread.sleep(2000);
//        e3.setHireDate(new Date());
//        System.out.println("E1:" + e1);
//        System.out.println("E3:" + e3);

//        Employee e4 = e1.clone();
//        e4.setHireDate(new Date());
//        System.out.println("深拷贝2");
//        System.out.println("E1:" + e1);
//        System.out.println("E4:" + e4);




    }

}
